package cn.zh.npro.Util;

import android.text.TextUtils;

/**
 * Created by Administrator on 2019/3/18.
 */

public class Tp {
    //长
    static String LengthString;
    //宽
    static String WidthString;

    static double unit_pricedouble;
    static double numberdouble;
    static Double ZongJia=0.0;

    /**
     * @param specifications 规格
     * @param unit_price     单价
     * @param number         数量
     * @param type           类型    // 米是1  平方米是2  卷是3
     * @return
     */

    // 1*2*3
    public static Double gettotalprice(String specifications, String unit_price, String number, String type) {
        if (!TextUtils.isEmpty(specifications) && !TextUtils.isEmpty(unit_price) && !TextUtils.isEmpty(number)) {
            int indexOf = specifications.indexOf("*");
            int indexOf2 = specifications.lastIndexOf("*");
            LengthString = "" + specifications.substring(0, indexOf);
            WidthString = "" + specifications.substring(indexOf + 1, indexOf2);
            double Lengthdouble = Double.valueOf(LengthString);
            double Widthdouble = Double.valueOf(WidthString);
            unit_pricedouble = Double.valueOf(unit_price);

            if (number.equals("")) {
                number = "0";
            }
            numberdouble = Double.valueOf(number);

            if (type.equals("1")) {
                ZongJia = Lengthdouble * unit_pricedouble * numberdouble;
//                return Lengthdouble * unit_pricedouble * numberdouble;

            }
            if (type.equals("2")) {
                ZongJia = Lengthdouble * Widthdouble * unit_pricedouble * numberdouble;
//                return Lengthdouble * Widthdouble * unit_pricedouble * numberdouble;
            }
            if (type.equals("3")) ;

        }
        return ZongJia;
    }
}
